package cn.hnu.jpa.jpaExample.OneToMany.SingleWay;


import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;

import org.junit.Test;


public class ModelUnitTest {

	//@Test
	public void test() {
		EntityManagerFactory emf = Persistence.createEntityManagerFactory("jpa");
		EntityManager em = emf.createEntityManager();
		em.getTransaction().begin();
		ModelCustomer cpk = new ModelCustomer();
		ModelAddr addr1 = new ModelAddr();
		ModelAddr addr2 = new ModelAddr();
		cpk.setName("zdc");
		addr1.setAddr("123456");
		addr2.setAddr("789012");
		cpk.getAddrs().add(addr1);
		cpk.getAddrs().add(addr2);
		em.persist(cpk);
		em.getTransaction().commit();
		em.close();
		emf.close(); 
	}

}
